package io.renren.modules.store.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.store.dao.TStoreRegionDao;
import io.renren.modules.store.entity.TStoreRegionEntity;
import io.renren.modules.store.service.TStoreRegionService;


@Service("tStoreRegionService")
public class TStoreRegionServiceImpl extends ServiceImpl<TStoreRegionDao, TStoreRegionEntity> implements TStoreRegionService {

    @Autowired
    private TStoreRegionDao storeRegionDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TStoreRegionEntity> page = this.page(
                new Query<TStoreRegionEntity>().getPage(params),
                new QueryWrapper<TStoreRegionEntity>()
                        .eq(!params.get("sellerId").equals(""),"seller_id",params.get("sellerId"))
                .eq(params.get("status") != null,"status",params.get("status"))
                .eq(params.get("storeTypeId")!=null,"store_type_id",params.get("storeTypeId"))
        );

        return new PageUtils(page);
    }

    @Override
    public List<TStoreRegionEntity> getRegionList(TStoreRegionEntity regionEntity) {
        return storeRegionDao.getRegionList(regionEntity);
    }

}